/*
 * HomeImageDecorateListItem.java
 * business
 *
 * Created by ChenTao on 2017/1/16.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.displaylistitem;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.yidiandao.business.data.imagemodule.DecorateImage;
import com.yidiandao.business.ui.url.UrlActivity;
import com.yidiandao.business.ui.widget.listview.DisplayListItem;
import com.yidiandao.business.ui.widget.listview.viewholder.HomeDecorateImageHolder;
import com.yidiandao.business.utils.ImageLoader;

/** 首页-顶部-图片装饰-ListItem */
public class HomeDecorateImageListItem
        extends DisplayListItem<HomeDecorateImageHolder, DecorateImage> {

    public HomeDecorateImageListItem(DecorateImage s) {
        super(s);
    }

    @Override
    public void onShow(final Context context, HomeDecorateImageHolder holder) {
        holder.rootLayout.setRatio(data.getRatio());
        ImageLoader.loadImage(context, holder.ivImage, data.getImage());

        holder.ivImage.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        UrlActivity.actionStart((Activity) context, data.getUrl());
                    }
                });
    }

    @Override
    public String getDisplayItemTag() {
        return HomeDecorateImageListItem.class.getSimpleName();
    }

    @Override
    public Class<HomeDecorateImageHolder> getViewHolderClazz() {
        return HomeDecorateImageHolder.class;
    }
}
